package com.ruitu.mall_98_2.mvp.presenter;

import com.beanu.arad.utils.ToastUtils;
import com.ruitu.mall_98_2.mvp.contract.CheckBillContract;
import com.ruitu.router_module.bean.api.BaseResult;
import com.ruitu.router_module.bean.api.SubscriberImpl;
import com.ruitu.router_module.bean.mine.Bills;

import java.util.List;

public class CheckBillPresenter extends CheckBillContract.Presenter {
    @Override
    public void bills(String accountId) {
        mModel.bills(accountId)
                .subscribe(new SubscriberImpl<BaseResult<List<Bills>>>() {
                    @Override
                    public void onError(Throwable e) {
                        mView.hideProgress();
                        mView.setFail();
                        ToastUtils.showShort("获取账单失败");
                    }

                    @Override
                    public void onNext(BaseResult<List<Bills>> listBaseResult) {
                        mView.hideProgress();
                        if (listBaseResult.isSuccess()) {
                            mView.setData(listBaseResult.getData());
                        }
//                        ToastUtils.showShort(listBaseResult.getMsg());
                    }
                });
    }
}
